Bank Server
In this example the Bank Server simulates an object wrapper for
a legacy bank system. The interface design follows the object manager
pattern. This example demonstrates how to:
-
Design interfaces using the object manager pattern
-
Implement interfaces using the TIE mechanism
-
Manage CORBA objects with a hash table
-
Implement thread-safe synchronized operations
This server can be used together with the ATM
Central Server (or ATM Central Server
- interface layer) in the ATM System Software case study.
Source Files
-
Bank.idl
IDL file for the interfaces AccountIF and AccountMgrIF in the bank
module. (IF stands for interface.) Also defined are exception
"BankError" and an account information structure AccInfo.
-
Server.java
The Server code, which has a main function that creates an instance
of the AccountMgrImpl class and calls obj_is_ready()and
impl_is_ready() to make it available to the client.
The code contains the following interface implementation classes:
-
AccountMgrImpl
Implementation for the account manager interface "AccountMgrIF". It
implements access control methods: login and logout,
and mangement methods: open (opens an account), remove (removes
an account), and showAccounts (shows the name of all accounts).
-
AccountImpl
Implementation for the interface "AccountIF". It implements
get methods: getBalance, getAccInfo, getHistory, and transaction
methods: deposit, withdraw, transferTo, payBill. Note that
all transactions are declared "synchronized" in order to allow multiple
client threads to perform the transactions safely.
-
Client.java
The client code. It binds to the AccountMgrImpl object
using a bank server name (e.g. "ABC_Bank_Account_Manager"). It then
waits for user commands to open accounts and to initiate transactions.
The runTerminal method translates command line inputs into method
calls to the server. One may also run the client with an input text
file that contains multiple command lines. An example is in Test1.txt.
Batch Files
-
build.bat
A batch file for building the client and server on Windows.
It will first invoke the IDL compiler and then compile the server and client
source codes. A subdirectory named "bank" will be created, which
contains the CORBA stub and skeleton codes and their corresponding class
files.
-
runsrv.bat
A batch file for running the server. The command line format
is:
runsrv [server_name]
The default server name is "ABC_Bank_Account_Manager".
client.bat
A batch file for running the client. The command line format
is:
client [hostname] [command.txt]
where the optional hostname (or IP address) is where the server is running
and command.txt is an optional input command file such as Test1.txt.
Running the Codes
This example was developed under VisiBroker (link).
To run the codes, make sure that the VisiBroker Smart Agent (osagent) is
running on the server object's network. Then enter the commands:
On Windows:
start runsrv
client (or client [hostname] [Test1.txt])
On Unix:
vbj Server &
vbj Client (or vbj Client [hostname] [Test1.txt])